home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdev4081.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.8 KB  |  96 lines

  1. /* Copyright (C) 1991, 1996 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdev4081.c,v 1.2 2000/09/19 19:00:11 lpd Exp $*/
  20. /* Ricoh 4081 laser printer driver */
  21. #include "gdevprn.h"
  22.  
  23. #define X_DPI 300            /* pixels per inch */
  24. #define Y_DPI 300            /* pixels per inch */
  25.  
  26. /* The device descriptor */
  27. private dev_proc_print_page(r4081_print_page);
  28. gx_device_printer far_data gs_r4081_device =
  29.   prn_device(prn_std_procs, "r4081",
  30.     85,                /* width_10ths, 8.5" */
  31.     110,                /* height_10ths, 11" */
  32.     X_DPI, Y_DPI,
  33.     0.25, 0.16, 0.25, 0.16,        /* margins */
  34.     1, r4081_print_page);
  35.  
  36. /* ------ Internal routines ------ */
  37.  
  38.  
  39. /* Send the page to the printer. */
  40. private int
  41. r4081_print_page(gx_device_printer *pdev, FILE *prn_stream)
  42. {    
  43.     int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
  44.     int out_size = ((pdev->width + 7) & -8) ;
  45.     byte *out = (byte *)gs_malloc(out_size, 1, "r4081_print_page(out)");
  46.     int lnum = 0;
  47.     int last = pdev->height;
  48.  
  49.     /* Check allocations */
  50.     if ( out == 0 )
  51.     {    if ( out )
  52.             gs_free((char *)out, out_size, 1,
  53.                 "r4081_print_page(out)");
  54.         return -1;
  55.     }
  56.  
  57.     /* find the first line which has something to print */
  58.     while ( lnum < last )
  59.     {
  60.         gdev_prn_copy_scan_lines(pdev, lnum, (byte *)out, line_size);
  61.         if ( out[0] != 0 ||
  62.              memcmp((char *)out, (char *)out+1, line_size-1)
  63.            )
  64.             break;
  65.         lnum ++;
  66.     }
  67.  
  68.     /* find the last line which has something to print */
  69.     while (last > lnum) {
  70.         gdev_prn_copy_scan_lines(pdev, last-1, (byte *)out, line_size);
  71.         if ( out[0] != 0 ||
  72.              memcmp((char *)out, (char *)out+1, line_size-1)
  73.            )
  74.             break;
  75.         last --;
  76.     }
  77.  
  78.     /* Initialize the printer and set the starting position. */
  79.     fprintf(prn_stream,"\033\rP\033\022YB2 \033\022G3,%d,%d,1,1,1,%d@",
  80.             out_size, last-lnum, (lnum+1)*720/Y_DPI);
  81.  
  82.     /* Print lines of graphics */
  83.     while ( lnum < last )
  84.        {
  85.         gdev_prn_copy_scan_lines(pdev, lnum, (byte *)out, line_size);
  86.         fwrite(out, sizeof(char), line_size, prn_stream);
  87.         lnum ++;
  88.        }
  89.  
  90.     /* Eject the page and reinitialize the printer */
  91.     fputs("\f\033\rP", prn_stream);
  92.  
  93.     gs_free((char *)out, out_size, 1, "r4081_print_page(out)");
  94.     return 0;
  95. }
  96.